package siar.web.managedbeans;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

import siar.webservice.BebidaBean;
import siar.webservice.ServicosSIARSoap;

public class BebidaMB {
	private List<BebidaBean> bebidas;
	
	public List<BebidaBean> getBebidas() {
		getBebidasWS();
		return bebidas;
	}

	public void getBebidasWS(){
		ServicosSIARSoap ws;
		try {
			ws = (ServicosSIARSoap) Naming.lookup("rmi://localhost/servicosSIAR");
			BebidaBean[] b;
			this.bebidas = new ArrayList<BebidaBean>();
			b = ws.bebidaListar();
			for(int i=0; i<b.length; i++){
				this.bebidas.add(b[i]);
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		}
	}
}
